/**
 * StaticMapStore.java 
 * Copyright © 2015-3015, 杭州泊享网络科技有限公司
 * 
 * @author Liu Tao
 * @create 2013年8月9日
 */
package com.pshare.tool;

import java.util.HashMap;
import java.util.Map;

/**
 * 保存在JVM内存里的数据。
 */
public class StaticMapStore {

    public interface Key {

        String PROVINCE = "province";

        String CITY = "city";

        String DISTRICT = "distrct";
        
        String PROVINCEMAP = "provincemap";

        String CITYMAP = "citymap";

        String DISTRICTMAP = "districtmap";	
        
        String LANDMARKMAP = "landmarkmap";
        
        String SERVERID = "serverId";
        
        String BANK = "bank";
        
        String DEPARTMENT = "department";
        String DEPARTMENTMAP = "departmentmap";
        String DEPARTMENT_HIERARCHY = "department_hierarchy";
        
        String POSITION = "position";
        String POSITIONMAP = "positionmap";
        
        String TITLE = "title";
        String TITLEMAP = "titlemap";
    }

    private volatile Map<String, Object> data = null;

    private static volatile StaticMapStore store = null;
    
    private static volatile String instanceMark = null;

    private StaticMapStore() {
        this.data = new HashMap<String, Object>();
    }

    public static StaticMapStore getInstance() {
        if (store == null) {
            synchronized (StaticMapStore.class) {
                if (store == null)
                    store = new StaticMapStore();
                return store;
            }
        }
        return store;
    }

    public void put(String key, Object value) {
        this.data.put(key, value);
    }

    public Object get(String key) {
        return this.data.get(key);
    }

    public boolean containsKey(String key) {
        return this.data.containsKey(key);
    }

    public void remove(String key) {
        this.data.remove(key);
    }

	public static String getInstanceMark() {
		return instanceMark;
	}

	public static void setInstanceMark(String instanceMark) {
		StaticMapStore.instanceMark = instanceMark;
	}
}
